using TMPro;
using UnityEngine;

public class NewMainMenuManager : MonoBehaviour
{
	public enum MainMenuStates
	{
		None,
		Title,
		Console,
		Hypothetical,
		Logs,
		Credits,
		Extras
	}

	public static NewMainMenuManager instance;

	[SerializeField]
	private GameObject FogCylinder;

	[SerializeField]
	private Light globalLight;

	[SerializeField]
	private TextMeshPro DeskNumber;

	public Animator CameraAnimator;

	public AudioSource MenuSource;

	public Animator HypoasterArms;

	public AudioClip SFX_MenuSelect;

	public AudioClip SFX_MenuMove;

	public AudioClip SFX_MenuDeny;

	public AudioClip SFX_MenuClick;

	public AudioClip SFX_MenuNotification;

	public AudioClip SFX_ComputerBootOff;

	public bool HypoasterHandsEnabled;

	[SerializeField]
	private GameObject TitleMenu;

	[SerializeField]
	private GameObject ConsoleMenu;

	[SerializeField]
	private GameObject HypotheticalMenu;

	[SerializeField]
	private GameObject LogMenu;

	[SerializeField]
	private GameObject CreditMenu;

	[SerializeField]
	private GameObject ExtraMenu;

	private void Awake()
	{
		instance = this;
		HypoasterArms.gameObject.SetActive(value: false);
		HypoasterHandsEnabled = false;
		if (!PlayerPrefs.HasKey("Game_DeskNumber"))
		{
			PlayerPrefs.SetInt("Game_DeskNumber", Random.Range(1, 99));
		}
		if (PlayerPrefs.GetInt("Game_DeskNumber", 0) <= 9)
		{
			DeskNumber.text = string.Format("00{0}", PlayerPrefs.GetInt("Game_DeskNumber", 0));
		}
		else
		{
			DeskNumber.text = string.Format("0{0}", PlayerPrefs.GetInt("Game_DeskNumber", 0));
		}
		PlayerPrefs.SetInt("Game_SingularVesselEditorMode", 0);
	}

	private void Start()
	{
		if (SettingsManager.Instance.GetBoolSettingValue("SimpleVFX"))
		{
			Object.Destroy(FogCylinder);
			globalLight.shadows = LightShadows.None;
		}
		UI_LoadingIcon.ToggleLoadingIcon(showIcon: false);
		GonerMenu.CurrentActiveHypothesis = null;
		GonerMenu.RecoveringFromGameOver = false;
		LightworldMenu.Instance.CanOpenMenu = false;
		DarkworldMenu.Instance.CanOpenMenu = false;
		LightworldInventory.Instance.ClearInventory();
		DarkworldInventory.Instance.ClearInventory();
		PartyMemberSystem.Instance.RemoveAllPartyMember();
		PlayerPrefs.SetInt("TimesPlayed", PlayerPrefs.GetInt("TimesPlayed", 0) + 1);
	}

	private void Update()
	{
		LightworldMenu.Instance.CanOpenMenu = false;
		DarkworldMenu.Instance.CanOpenMenu = false;
		if (HypoasterHandsEnabled)
		{
			HypoasterHandsUpdate();
		}
	}

	private void HypoasterHandsUpdate()
	{
		if (ConsoleMenu.activeSelf)
		{
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up))
			{
				HypoasterArms.Play("NewBootUp_HypoasterArms_RightType_Up", 1, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Down))
			{
				HypoasterArms.Play("NewBootUp_HypoasterArms_RightType_Down", 1, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Left))
			{
				HypoasterArms.Play("NewBootUp_HypoasterArms_RightType_Left", 1, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArms.Play("NewBootUp_HypoasterArms_RightType_Right", 1, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Confirm))
			{
				HypoasterArms.Play($"NewBootUp_HypoasterArms_LeftType{Random.Range(1, 2)}", 0, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Menu))
			{
				HypoasterArms.Play($"NewBootUp_HypoasterArms_LeftType{Random.Range(1, 2)}", 0, 0f);
			}
			else if (Input.GetKeyDown(PlayerInput.Instance.Key_Cancel))
			{
				HypoasterArms.Play($"NewBootUp_HypoasterArms_LeftType{Random.Range(1, 2)}", 0, 0f);
			}
		}
	}

	public void EnableHypoasterHands()
	{
		HypoasterArms.gameObject.SetActive(value: true);
		HypoasterHandsEnabled = true;
		HypoasterArms.Play("NewBootUp_HypoasterArms_PrepareLeftTyping", 0);
		HypoasterArms.Play("NewBootUp_HypoasterArms_PrepareRightTyping", 1);
	}

	public void HypoasterHideHandsAnimation()
	{
		HypoasterArms.Play("NewBootUp_HypoasterArms_StopTyping", 0);
		HypoasterArms.Play("NewBootUp_HypoasterArms_StopRightTyping", 1);
	}

	public void SetMainMenuState(MainMenuStates state)
	{
		switch (state)
		{
		case MainMenuStates.Console:
			TitleMenu.SetActive(value: false);
			ConsoleMenu.SetActive(value: true);
			ExtraMenu.SetActive(value: false);
			EnableHypoasterHands();
			CameraAnimator.Play("MainMenu_Camera_MonitorIdle");
			break;
		case MainMenuStates.Hypothetical:
			TitleMenu.SetActive(value: false);
			HypotheticalMenu.SetActive(value: true);
			ConsoleMenu.SetActive(value: false);
			ExtraMenu.SetActive(value: false);
			EnableHypoasterHands();
			CameraAnimator.Play("MainMenu_Camera_MonitorZoomIn", 0, 1f);
			break;
		case MainMenuStates.Logs:
			TitleMenu.SetActive(value: false);
			HypotheticalMenu.SetActive(value: true);
			EnableHypoasterHands();
			CameraAnimator.Play("MainMenu_Camera_MonitorZoomIn", 0, 1f);
			break;
		case MainMenuStates.Credits:
			TitleMenu.SetActive(value: false);
			HypotheticalMenu.SetActive(value: true);
			EnableHypoasterHands();
			CameraAnimator.Play("MainMenu_Camera_MonitorZoomIn", 0, 1f);
			break;
		case MainMenuStates.Extras:
			TitleMenu.SetActive(value: false);
			HypotheticalMenu.SetActive(value: false);
			ExtraMenu.SetActive(value: true);
			EnableHypoasterHands();
			CameraAnimator.Play("MainMenu_Camera_MonitorZoomIn", 0, 1f);
			break;
		case MainMenuStates.Title:
			break;
		}
	}
}
